package com.whl.cloud.oauth;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.security.crypto.password.PasswordEncoder;
import org.springframework.stereotype.Component;

import com.whl.cloud.fergn.UserCenter;
import com.whl.cloud.model.UserPasswordCheckParam;

@Component
public class WhlPasswordEncoder implements PasswordEncoder {
	@Autowired
	UserCenter userCenter;

	@Override
	public String encode(CharSequence rawPassword) {
		return rawPassword.toString();
	}

	@Override
	public boolean matches(CharSequence rawPassword, String encodedPassword) {
		UserPasswordCheckParam param = new UserPasswordCheckParam();
		param.setUserId(Long.valueOf(encodedPassword));
		param.setPassword(rawPassword.toString());
		return userCenter.checkPassword(param);
	}

}
